<template>
	<view class="uni_box home">
		<navbar title='开通员工'>
		</navbar>
		<view class="content">
			<view class="shoulist">
				<view class="shouitem">
					<text class="sname">手机号</text>
					<view class="sinput">
						<u-input v-model="mobile" type="text" :border="false" placeholder='请输入' />
					</view>
				</view>
				<view class="baocun" @click="getbaocun">保存</view>
			</view>
			
			<view class="srview">
				
				<view class="sclist">
					<text class="yuantit">员工列表</text>
					<view class="scitem" v-for="(item,index) in list" :key="index">
						<image class="tuicon" :src="ossThree(item.avatar)" mode="" />
						<view class="sright">
							<view class="tione">
								<text class="tiname">{{ item.realname }}</text>
								<text class="tiname ml">{{item.mobile}}</text>
							</view>
						</view>
					</view>
					<u-loadmore style="margin-top: 30rpx;" :status="status" @loadmore="loadmore" />
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tablist: [{
					name: '全部'
				},{
					name: '收入'
				}, {
					name: '支出'
				}],
				current: 0,
				list: [],
				page: 1,
				limit: 10,
				last_page: 1,
				status: "loadmore",
				user:{},
				identity:1,
				mobile:''
			}
		},
		onLoad(option) {
			if(option.type){
				this.identity = option.type
			}
			this.getList();
			this.getuser()
		},
		onShow() {
		},
		onReachBottom: function () {
			this.loadmore();
		},
		methods: {
			async getuser(){
				let res = await this.$u.api.user({
				});
				this.user = res.data

			},
			change(e){
				this.current = e
				this.getClear()
			},
			getzhanghu(){
				this.navrouter("/pages_client/twoPage/M-AccountManage");
			},
			gettixian(e){
				this.navrouter("/pages_client/twoPage/Tixian?type="+e);
			},
			async getList(){//列表数据
				let res;
				res = await this.$u.api.getYuanGong({
						limit:this.limit,
						page:this.page
					});
				
					let list = res.list;
					this.list = this.page == 1 ? list : [...this.list, ...list];	
					if(res.list==''||Number(list.length)<Number(this.limit)){
						this.status = 'nomore';
					}
				
			},
			loadmore() {
				let page = this.page;
				// let last_page = this.last_page;
				if (this.status == 'loadmore') {
					this.page++;
					this.getList();
				}
			},
			getClear(){
				this.list = []
				this.page = 1,
				this.status= "loadmore"
				this.getList()
			},
			async getbaocun(){
				let res;//addAccount editAccount
				if(!this.mobile){
					this.$u.toast("请输入员工手机号");
					return;
				}
				res = await this.$u.api.addYuangong({
					mobile:this.mobile
				});
				this.$u.toast("添加成功");
				this.getClear()
				
			},
		}
	}
</script>

<style lang="scss" scoped>
	page{
		background-color: #F5f5f5;
	}
	.zhu{
		height: 68rpx;
		background: #EEEEEE;
		border-radius: 30rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
		padding: 0 30rpx;
		margin-bottom: 20rpx;
		.zname{
			font-weight: 500;
			font-size: 26rpx;
			color: #222222;
		}
		.icon_nexthui{
			margin-left: auto;
			width: 24rpx;
			height: 24rpx;
		}
	}
	.content{
		background-color: #F5f5f5;
		padding: 25rpx;
		min-height: 100vh;
		.qone{
			position: relative;
			height: 210rpx;
			width: 100%;
			
			.qbitem{
				position: relative;
				padding: 40rpx;
				display: flex;
				flex-direction: row;
				display: flex;
				flex-direction: row;
				align-items: center;
				.qbleft{
					display: flex;
					flex-direction: column;
					flex: 1;
					// padding-right: 30rpx;

					.qbhead{
						display: flex;
						flex-direction: row;
						align-items: center;
						.sname{
							font-weight: 500;
							font-size: 26rpx;
							color: #FFFFFF;
						}
						.tixian{
							width: 100rpx;
							height: 44rpx;
							background: #FFFFFF;
							border-radius: 22rpx;
							display: flex;
							margin-left: auto;
							align-items: center;
							justify-content: center;
							font-weight: 500;
							font-size: 24rpx;
							color: #EA5918;
						}
					}
					.qian{
						font-weight: bold;
						font-size: 26rpx;
						color: #FFFFFF;
						margin-top: 25rpx;
						display: block;
					}
					.qiannum{
						font-size: 40rpx;
						display: inline-block;
						margin-left: 9rpx;
						top: 3rpx;
						position: relative;
					}
				}
				.qbleft:last-child{
					// padding-right: 0;
					// padding-left: 40rpx;
				}
			}
			.shu{
				width: 2rpx;
				height: 50rpx;
				background: #FFFFFF;
				opacity: 0.5;
				display: inline-block;
			}
		}
	}
	.srview{
		margin: 40rpx 0 30rpx;
	}
	.sclist{
		background-color: #fff;
		padding: 30rpx;
		border-radius: 20rpx;
		.scitem{
			display: flex;
			padding: 30rpx 0 ;
			border-bottom: 1rpx solid #eee;
			flex-direction: row;
			align-items: center;
			.tuicon{
				margin-right: 20rpx;
				width: 80rpx;
				height: 80rpx;
			}
			.sright{
				// width: 80%;
				flex: 1;
				display: flex;
				flex-direction: column;
				.tione{
					display: flex;
					flex-direction: row;
					align-items: center;
					margin-bottom: 10rpx;
					.tiname{
						font-weight: bold;
						font-size: 28rpx;
						color: #333333;
					}
					.timiao{
						font-weight: 400;
						font-size: 24rpx;
						color: #666666;
					}
				}
				.tione:last-child{
					margin-bottom: 0;
				}
			}
		}
	}
	.shoulist{
	background-color: #fff;
	border-radius: 30rpx;
	padding: 30rpx;
	.shouitem{
		display: flex;
		flex-direction: column;
		margin-bottom: 30rpx;
		.sname{
			font-weight: bold;
			font-size: 32rpx;
			color: #111111;
			display: block;
			margin-bottom: 30rpx;
		}
		.sinput{
			background: #F5F5F5;
			border-radius: 50rpx;
			padding: 5rpx 30rpx;
		}
	}
	.shouitem:last-child{
		margin-bottom: 0;
	}
}
.baocun{
		height: 90rpx;
		background: linear-gradient(90deg, #FF8F39, #FF4D43);
		border-radius: 45rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		font-weight: bold;
		font-size: 28rpx;
		color: #FFFFFF;
		margin-top: 70rpx;
	}
	.yuantit{
		color: #FF8F39;
		font-size: 36rpx;
		font-weight: 500;
		
	}
</style>
